<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>js解析xml文档</title>
</head>
<body>
</body>
</html>
<script type="text/javascript">
    // __STATIC__/fy/info.xml

    if (window.XMLHttpRequest) {
        xmlhttp=new XMLHttpRequest();
    } else {
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.open("GET","__STATIC__/fy/info.xml",false);
    xmlhttp.send();
    xmlDoc=xmlhttp.responseXML;
    console.log(xmlDoc);
    var elements = xmlDoc.getElementsByTagName("data");
    console.log(elements);
    for (var i = 0; i < elements.length; i++) {
        var id = elements[i].getAttribute('id');
        var name = elements[i].getAttribute('name');
        document.write('<p>序号：'+(i+1)+'&nbsp;&nbsp;&nbsp;id：'+id+'<span>&nbsp;&nbsp;&nbsp;name：'+name+'</span></p>');
    }
</script>
